<?php
	if(count($friends)>0)
	foreach($friends as $row){
		echo $row->fusername;
	}
	else
		echo '暂时没有好友，现在就去<a href="'.base_url().'friends/search">找朋友</a>?';
	
	    function rad($d)  
    {  
        return $d * 3.1415926535898 / 180.0;  
    }  
    function GetDistance($lat1, $lng1, $lat2, $lng2)  
    {  
        $EARTH_RADIUS = 6378.137;  
        $radLat1 = rad($lat1);  
        //echo $radLat1;  
       $radLat2 = rad($lat2);  
       $a = $radLat1 - $radLat2;  
       $b = rad($lng1) - rad($lng2);  
       $s = 2 * asin(sqrt(pow(sin($a/2),2) +  
        cos($radLat1)*cos($radLat2)*pow(sin($b/2),2)));  
       $s = $s *$EARTH_RADIUS;
       $s = round($s, 2);  //保留2位有效数字
       return $s;  
    }  
    
    echo '距离是：'.GetDistance(40.03313,116.316645, 39.934202, 116.289855).'公里';
?>
